﻿using System;
using JStore.Core.Entities;
using SpeadFrm.ORM;

namespace JStore.Data.Daos
{
    public class CompanyMoneyLogDao : BaseDao<CompanyMoneyLog>
    {
        public decimal GetSum(DateTime startDate, DateTime endDate)
        {
            var sql = Sql.Builder
                .Append("SELECT ISNULL(SUM(RealMoney),0.00)")
                .Append("FROM CompanyMoneyLog")
                .Where("DATEDIFF(DAY,CreateDate,@0) <=0 AND DATEDIFF(DAY,CreateDate,@1) >= 0", startDate, endDate);
            return FirstOrDefault<decimal>(sql);
        }
    }
}